using System;
using System.Xml.Serialization;
using CodePlex.DnD4eCampaignManager.DnD4e;
using CodePlex.DnD4eCampaignManager.DnD4e.Interfaces;

namespace CodePlex.DnD4eCampaignManager.Repositories.XmlRepositories
{
    public class MonsterXmlRepository : BaseXmlRepository<IMonster>, IMonsterRepository
    {
        private static readonly XmlSerializer XML_SERIALIZER = new XmlSerializer(typeof ( Monster ));

        public MonsterXmlRepository()
        {
            InitializeRepository();
        }

        protected override string Extension
        {
            get { return ".monster"; }
        }

        protected override string Folder
        {
            get { return "Monsters"; }
        }

        protected override XmlSerializer XmlSerializer
        {
            get { return XML_SERIALIZER; }
        }

        public new void Save(IMonster domainObject)
        {
            if ( domainObject.Index.HasValue )
            {
                return;
            }
            base.Save(domainObject);
        }
    }
}